using System;
using System.Collections.Generic;
using System.Text;

namespace Tomahawk.Runtime.Logic
{
    /// <summary>
    /// A Controller is an object that can send commands into a Pawn.
    /// </summary>
    public abstract class XController : XObject
    {

        #region "Pawn relationship"

        private XPawn controlledPawn = null;

        /// <summary>
        /// The pawn this controller operates on
        /// </summary>
        public XPawn ControlledPawn
        {
            get { return this.controlledPawn; }
            set { this.controlledPawn = value; }
        }

        /// <summary>
        /// Derived types must implement this method with an appropiate mechanism to 
        /// let the associated pawn to get the message command
        /// </summary>
        public abstract void SendCommand(XPawn.PawnCommand command);

        #endregion

        #region "Exceptions"

        /// <summary>
        /// To be raised when a Pawn cannot handle a certain type of command
        /// </summary>
        public class NoPawnAsignedException : LogicException
        {
            public NoPawnAsignedException(XPawn.PawnCommand command)
                : base("The controller has no pawn assigned to pass on the given command: " + command.GetType().FullName, null) { }
        }

        #endregion

    }

}
